<?php
defined ('_VALID_MOS') or
    die('Direct Access to this location is not allowed');
?>
<table class="adminlist" cellspacing="1">
    <thead>
        <tr>
            <th width="5">
                <?php echo JText::_( $this->translate->_('Num') ); ?>
            </th>
            <th width="15%">

            </th>
            <th class="title">
                <?php echo JHTML::_('grid.sort',   $this->translate->_('module'), 'c.module', $this->orderDir, $this->order ); ?>
            </th>
            <th class="title">
                <?php echo JHTML::_('grid.sort',   $this->translate->_('location'), 'c.module', $this->orderDir, $this->order ); ?>
            </th>
            <th width="1%" nowrap="nowrap">
                <?php echo JHTML::_('grid.sort',   $this->translate->_('published'), 'c.state', $this->orderDir, $this->order ); ?>
            </th>
        </tr>
    </thead>
    <tbody>
        <?php $count = 1;
        if($this->modules!= NULL):
        foreach($this->modules as $row) : 
            if(strlen($row->params)>0) {
               $params = json_decode($row->params);
               if(strlen($params->addparams)>0) {
                   $addparams = json_decode($params->addparams);
               } else {
                   $addparams=NULL;
               }
            } else {
                $addparams=NULL;
            }
               ?>
        <tr class="<?php echo "row".($count%2); ?>">
            <td>
                <?php echo $count;?>
            </td>
            <td>
                <a href="<?php echo JRoute::_($this->url(array(
                    'module'=>'Facebook',
                    'controller'=>'comments',
                    'action'=>'edit',
                    'addparams'=> json_encode(array(
                        'id'=>$row->id,
                    )),
                ),'administrator'));?>" title="Edit" class="ui-button ui-state-default ui-corner-all"
                   style="padding: .4em 1em;">
                    Edit
                </a>
                <a href="index.php?option=com_modules&task=module.edit&id=<?php echo $row->id;?>"
                   title="Edit Joomla Module" class="ui-button ui-state-default ui-corner-all"
                   style="padding: .4em 1em;">
                    Edit Joomla Module
                </a>
            </td>
            <td>
                <?php if($addparams!=NULL && strlen($addparams->title)>0) {
                    echo $addparams->title;
                } else {
                    echo $row->title;
                }?>
            </td>
            <td>
                <?php echo $row->position;?>
            </td>
            <td align="center">
                <a href="javascript:void(0);">
                <img src="templates/<?php echo $this->template;?>/images/admin/<?php
                    echo $row->published != 0 ? 'tick.png' : 'disabled.png';
                    ?>" width="16" height="16" border="0"
                    alt="Publish" /> &nbsp;
                </a>
            </td>
        </tr>
        <?php $count++;
            endforeach;
        ?>
        <tr>
            <td colspan ="10">
                <a href="<?php echo $this->Jurl(array(
                    'module'=>'Facebook',
                    'controller'=>'comments',
                    'action'=>'add',
                ),'administrator');?>"
                   title="<?php echo $this->translate->_('Add Module');?>" 
                   class="ui-button ui-state-default ui-corner-all">
                    <?php echo $this->translate->_('Add Module');?>
                </a>
                <a href="<?php echo $this->Jurl(array(
                    'module'=>'Facebook',
                    'controller'=>'index',
                    'action'=>'adminindex',
                ),'administrator');?>"
                   title="<?php echo $this->translate->_('Back');?>" 
                   class="ui-button ui-state-default ui-corner-all">
                    <?php echo $this->translate->_('Back');?>
                </a>
            </td>
        </tr>
        <?php endif;?>
    </tbody>
</table>